this._power = new imports.ui.status.power.Indicator();
this._powerProfiles = new imports.ui.status.powerProfiles.Indicator();
- this._rfkill = new imports.ui.status.rfkill.Indicator();
this._volume = new imports.ui.status.volume.Indicator();
this._brightness = new imports.ui.status.brightness.Indicator();
this._system = new imports.ui.status.system.Indicator();
this._indicators.add_child(this._network);
if (this._bluetooth)
this._indicators.add_child(this._bluetooth);
- this._indicators.add_child(this._rfkill);
this._indicators.add_child(this._volume);
this._indicators.add_child(this._power);
this._indicators.add_child(this._powerProfiles);
if (this._bluetooth)
this.menu.addMenuItem(this._bluetooth.menu);
- this.menu.addMenuItem(this._rfkill.menu);
this.menu.addMenuItem(this._power.menu);
this.menu.addMenuItem(this._powerProfiles.menu);
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this.menu.addMenuItem(this._system.menu);
- menuLayout.addSizeChild(this._rfkill.menu.actor);
menuLayout.addSizeChild(this._power.menu.actor);
menuLayout.addSizeChild(this._powerProfiles.menu.actor);
menuLayout.addSizeChild(this._system.menu.actor);
this._location = new imports.ui.status.location.Indicator();
this._thunderbolt = new imports.ui.status.thunderbolt.Indicator();
this._nightLight = new imports.ui.status.nightLight.Indicator();
+ this._rfkill = new imports.ui.status.rfkill.Indicator();
this._unsafeMode = new UnsafeModeIndicator();
this._indicators.add_child(this._remoteAccess);
this._indicators.add_child(this._thunderbolt);
this._indicators.add_child(this._location);
this._indicators.add_child(this._nightLight);
+ this._indicators.add_child(this._rfkill);
this._indicators.add_child(this._unsafeMode);
this._addItems(this._remoteAccess.quickSettingsItems);
this._addItems(this._thunderbolt.quickSettingsItems);
this._addItems(this._location.quickSettingsItems);
this._addItems(this._nightLight.quickSettingsItems);
+ this._addItems(this._rfkill.quickSettingsItems);
this._addItems(this._unsafeMode.quickSettingsItems);
}
const {Gio, GLib, GObject} = imports.gi;
-const Main = imports.ui.main;
-const PanelMenu = imports.ui.panelMenu;
-const PopupMenu = imports.ui.popupMenu;
+const {QuickToggle, SystemIndicator} = imports.ui.quickSettings;
const {loadInterfaceXML} = imports.misc.fileUtils;
return _manager;
}
-var Indicator = GObject.registerClass(
-class Indicator extends PanelMenu.SystemIndicator {
+const RfkillToggle = GObject.registerClass(
+class RfkillToggle extends QuickToggle {
_init() {
- super._init();
+ super._init({
+ label: _('Airplane Mode'),
+ iconName: 'airplane-mode-symbolic',
+ });
this._manager = getRfkillManager();
- this._manager.connect('notify', () => this._sync());
+ this._manager.bind_property('show-airplane-mode',
+ this, 'visible',
+ GObject.BindingFlags.SYNC_CREATE);
+ this._manager.bind_property('airplane-mode',
+ this, 'checked',
+ GObject.BindingFlags.SYNC_CREATE);
+
+ this.connect('clicked',
+ () => (this._manager.airplaneMode = !this._manager.airplaneMode));
+ }
+});
+
+var Indicator = GObject.registerClass(
+class Indicator extends SystemIndicator {
+ _init() {
+ super._init();
this._indicator = this._addIndicator();
this._indicator.icon_name = 'airplane-mode-symbolic';
- this._indicator.hide();
-
- // The menu only appears when airplane mode is on, so just
- // statically build it as if it was on, rather than dynamically
- // changing the menu contents.
- this._item = new PopupMenu.PopupSubMenuMenuItem(_("Airplane Mode On"), true);
- this._item.icon.icon_name = 'airplane-mode-symbolic';
- this._offItem = this._item.menu.addAction(_("Turn Off"), () => {
- this._manager.airplaneMode = false;
- });
- this._item.menu.addSettingsAction(_("Network Settings"), 'gnome-network-panel.desktop');
- this.menu.addMenuItem(this._item);
- Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
- this._sessionUpdated();
+ this._rfkillToggle = new RfkillToggle();
+ this._rfkillToggle.connectObject(
+ 'notify::visible', () => this._sync(),
+ 'notify::checked', () => this._sync(),
+ this);
+ this.quickSettingsItems.push(this._rfkillToggle);
this._sync();
}
- _sessionUpdated() {
- let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
- this.menu.setSensitive(sensitive);
- }
-
_sync() {
- const {airplaneMode, hwAirplaneMode, showAirplaneMode} = this._manager;
-
- this._indicator.visible = airplaneMode && showAirplaneMode;
- this._item.visible = airplaneMode && showAirplaneMode;
- this._offItem.setSensitive(!hwAirplaneMode);
-
- if (hwAirplaneMode)
- this._offItem.label.text = _("Use hardware switch to turn off");
- else
- this._offItem.label.text = _("Turn Off");
+ // Only show indicator when airplane mode is on
+ const {visible, checked} = this._rfkillToggle;
+ this._indicator.visible = visible && checked;
}
});